package com.lxw.manage_cms.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Controller
public class FreemakerController {


    @RequestMapping("/banner")
    public String index_banner(Model model) {
        RestTemplate restTemplate = new RestTemplate();
        String forObject = restTemplate.getForObject("http://localhost:31001/cms/cmsConfig/fiandById/5a791725dd573c3574ee333f", String.class);
        JSONObject jsonObject = JSON.parseObject(forObject);
        JSONArray jsonArray = jsonObject.getJSONArray("model");
        model.addAttribute("model", jsonArray);

        return "banner";
    }
}
